var express = require('express');
var conn = require('../public/javascripts/connect');
var router = express.Router();

/* GET home page. */
router.get('/', async function (req, res, next) {
    let Year, Month, tableArr = [], user = {};
    //查询语句
    let sql = `SELECT * FROM 包头项目部_2018_7 ORDER BY '行号'`;
    let sqlZiduan = `SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE table_name = '包头项目部_2018_7'`;

    await new Promise(resP=>{
        conn.connection2.query(sqlZiduan, function (err, result, fields) {
            if (err) {
                console.log('[SELECT ERROR] - ', err.message);
                return;
            }
            console.log("result", result)
            user.data_field = result;
            resP(true)
        });
    })

    console.log(sql);
    conn.connection2.query(sql, function (err, result, fields) {
        if (err) {
            console.log('[SELECT ERROR] - ', err.message);
            return;
        }
        console.log("result111", result);
        user.data_result = result
        res.render('yicheng', user);
    });
});
router.post("/",async function(req,res,next){
    console.log(1111)
})

module.exports = router;